package com.ziyia.activitytest;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SecondActivity extends BaseActivity {

    private static final String TAG = SecondActivity.class.getSimpleName();

    @BindView(R.id.button2)
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);

        setTitle(TAG);
        ButterKnife.bind(this);
//        Log.d(TAG, this.toString());
        Log.d(TAG, "TaskId = " + getTaskId());

//        Intent intent = getIntent();
//        String name = intent.getStringExtra("name");
//        Toast.makeText(this, name, Toast.LENGTH_SHORT).show();

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent1 = new Intent();
//                intent1.putExtra("name", "嘿嘿");
//                setResult(RESULT_OK, intent1);
//                finish();

                Intent intent = new Intent(SecondActivity.this, ThirdActivity.class);
                startActivity(intent);

            }
        });
    }

    public static void actionStart(Context context, String p1, String p2) {
        Intent intent = new Intent(context, SecondActivity.class);
        intent.putExtra("p1", p1);
        intent.putExtra("p2", p2);
        context.startActivity(intent);
    }

    @Override
    public void onBackPressed() {
        Intent intent1 = new Intent();
        intent1.putExtra("name", "嘿嘿");
        setResult(RESULT_OK, intent1);
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy: ");
    }
}